package com.probox.modules.controller.platfom;

import com.probox.common.core.web.controller.BaseController;
import com.probox.common.core.web.domain.AjaxResult;
import com.probox.common.core.web.page.TableDataInfo;
import com.probox.common.log.annotation.Log;
import com.probox.common.log.enums.BusinessType;
import com.probox.common.security.annotation.PreAuthorize;
import com.probox.common.entity.domain.platfom.PlatformFreightMoudle;
import com.probox.common.entity.domain.platfom.vo.PlatformFreightMoudleVo;
import com.probox.common.entity.service.platfom.IPlatformFreightMoudleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 平台邮费模板Controller
 *
 * @author usoft
 * @date 2021-06-28
 */
@RestController
@RequestMapping("/platform/moudle")
public class PlatformFreightMoudleController extends BaseController {
    @Autowired
    private IPlatformFreightMoudleService platformFreightMoudleService;

    /**
     * 查询平台邮费模板列表
     */
    @PreAuthorize(hasPermi = "platform:moudle:list")
    @GetMapping("/list")
    public TableDataInfo list(PlatformFreightMoudle platformFreightMoudle) {
        startPage();
        List<PlatformFreightMoudle> list = platformFreightMoudleService.queryList(platformFreightMoudle);
        return getDataTable(list);
    }


    /**
     * 获取平台邮费模板详细信息
     */
    @PreAuthorize(hasPermi = "platform:moudle:query")
    @GetMapping(value = "/{moudleUid}")
    public AjaxResult getInfo(@PathVariable("moudleUid") Long moudleUid) {
        return AjaxResult.success(platformFreightMoudleService.getVo(moudleUid));
    }

    /**
     * 新增平台邮费模板
     */
    @PreAuthorize(hasPermi = "platform:moudle:add")
    @Log(title = "平台邮费模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlatformFreightMoudleVo vo) {
        return toAjax(platformFreightMoudleService.insertPlatformFreightMoudle(vo));
    }

    /**
     * 修改平台邮费模板
     */
    @PreAuthorize(hasPermi = "platform:moudle:edit")
    @Log(title = "平台邮费模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlatformFreightMoudle platformFreightMoudle) {
        return toAjax(platformFreightMoudleService.updatePlatformFreightMoudle(platformFreightMoudle));
    }

    /**
     * 删除平台邮费模板
     */
    @PreAuthorize(hasPermi = "platform:moudle:remove")
    @Log(title = "平台邮费模板", businessType = BusinessType.DELETE)
    @DeleteMapping("/{moudleUids}")
    public AjaxResult remove(@PathVariable Long[] moudleUids) {
        return toAjax(platformFreightMoudleService.deletePlatformFreightMoudleByIds(moudleUids));
    }
}
